// This File is part of Innovation Foundry's "QualityHelper Project"
//
// Copyright  2008 Innovation Foundry Pty Ltd
// All rights reserved

// This work is free software; you can redistribute it and/or modify 
// it under the terms of the GNU General Public License as published 
// by the Free Software Foundation; either version 3 of the License, 
// or any later version. This work is distributed in the hope that 
// it will be useful, but WITHOUT ANY WARRANTY; without even the 
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
// PURPOSE. 
// See version 3 of the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this work; if not, write to the
// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA  02110-1301 USA
// or alternatively it may be downloaded from <http://www.gnu.org/licenses/>.

//Describes a document
var Dokument = Class.create({
    initialize: function(documentID, documentName, documentDescription, originURL, imageURL, md5Checksum, dateUpdated, documentExtension) {
        this.documentID = documentID;
        this.documentName = documentName;
        this.documentDescription = documentDescription;
        this.originURL = originURL;
        this.imageURL = imageURL;
        this.md5Checksum = md5Checksum;
        this.dateUpdated = dateUpdated;
        this.documentExtension = documentExtension;
    }
});


//Describes the flowchart piece used
var Purpose = Class.create({
  initialize: function(purposeName, flowchartElement) {
    this.purposeName = purposeName;
    this.flowchartElement = flowchartElement
  }
});

//Describes the user group
var Group = Class.create({
  initialize: function(groupName) {
    this.groupName = groupName;
  }
});

//Describes the connection type 
var ConnectionType = Class.create({
  initialize: function(connectionTypeName, colorRGBHex) {
    this.connectionTypeName = connectionTypeName;
    this.colorRGBHex = colorRGBHex;
  }
});

//Describes the connection (line connecting flowchart pieces)
var Connection = Class.create({
initialize: function(origin, destination, connectionType) {
    this.destination = destination;
    this.origin = origin;
    this.connectionType = connectionType;
  }

});

//Describes the reference (virtual procedure connection)
var Referenz = Class.create({
    initialize: function(origin, destination) {
        this.destination = destination;
        this.origin = origin;
    }
});

//Describes the procedure
var Procedure = Class.create({
    initialize: function(procedureID, procedureName, procedureDescription, purpose) {
        this.procedureID = procedureID;
        this.procedureName = procedureName;
        this.procedureDescription = procedureDescription;
        this.purpose = purpose;
        this.aliases = new Array(); //this will be just string array
        this.groups = new Array();
        this.inboundConnections = new Array();
        this.outboundConnections = new Array();
        this.inboundReferences = new Array();
        this.outboundReferences = new Array();
    },
    GetInboudConnections: function() {
        return this.inboundConnections;
    },
    AddInboundConnection: function(inboundConnection) {
        this.inboundConnections[this.inboundConnections.length] = inboundConnection;
    },
    GetOutboundConnections: function() {
        return this.outboundConnections;
    },
    AddOutboundConnection: function(outboundConnection) {
        this.outboundConnections[this.outboundConnections.length] = outboundConnection;
    },
    GetInboudReferences: function() {
        return this.inboundReferences;
    },
    AddInboundReference: function(inboundReference) {
        this.inboundReferences[this.inboundReferences.length] = inboundReference;
    },
    GetOutboundReferences: function() {
        return this.outboundReferences;
    },
    AddOutboundReference: function(outboundReference) {
        this.outboundReferences[this.outboundReferences.length] = outboundReference;
    },    
    GetGroups: function() {
        return this.groups;
    },
    AddGroup: function(group) {
        this.groups[this.groups.length] = group;
    },
    GetProcedureDescription: function() {
        return this.procedureDescription;
    },
    GetPurpose: function() {
        return this.purpose;
    },
    GetAliases: function() {
        return this.aliases;
    },
    AddAlias: function(aliasName) {
        if (this.aliases == null)
            this.aliases[this.aliases.length] = aliasName;
    }
});

//Data native or JSON for Silverlight access starts below
//Describes an entire diagram
var Diagram = Class.create({
    initialize: function(diagramID, procedureRoot, procedures, connections) {
        this.diagramID = diagramID;
        this.procedureRoot = procedureRoot;
        //ONLY FOR DATA EXAMPLE, REPLACE WITH REAL QUENCH
        this.procedures = procedures;
        this.connections = connections;
    }
});
